const os = require('os')
module.exports = {
  getIP() {
    //获取本机ip
    let getIPAdress = function () {
      var interfaces = os.networkInterfaces();
      // console.log('', interfaces)
      for (var devName in interfaces) {
        var iface = interfaces[devName];
        for (var i = 0; i < iface.length; i++) {
          var alias = iface[i];
          if (alias.family === 'IPv4' && alias.address !== '127.0.0.1' && !alias.internal) {
            return alias.address;
          }
        }
      }
    }
    let ip = getIPAdress();
    console.log('当前机器IP为：'+ip);// 192.168.0.4
    return ip;
  }
}